package j01jinzhi;

import java.math.BigDecimal;

public class J02float {
    public static void main(String[] args) {
        //0.1二进制（死循环），反码，补码
        double d1 = 0.1 + 0.2;
        System.out.println(d1);
        System.out.println(d1 == 0.3);


        System.out.println("====");
        BigDecimal b1 = new BigDecimal("0.1");
        BigDecimal b2 = new BigDecimal("0.2");
        BigDecimal he = b1.add(b2);

        BigDecimal b3 = new BigDecimal("0.3");
        System.out.println(he == b3);//false
        System.out.println(he.compareTo(b3));//0
    }
}
